# !/usr/bin/env python
# -*- coding: utf-8 -*-
import pandas as pd

if __name__ == '__main__':
    # 1.字典创建
    data = {
        "name": ["wind", "ccc", "aaa"],
        "age": [21, 18, 20],
        "height": [175, 163, 180],
        "sex": ["m", "w", "m"]
    }
    df = pd.DataFrame(data)
    print("dict", df)

    data = [['Tom', 10],
            ['Nick', 15],
            ['John', 16]]

    df2 = pd.DataFrame(data, columns=['Name', 'Age'])
    print("list", df2)


    print("index", df.index)
    print("column", df.columns)

    # 获取一行或多行数据
    print(df.loc[0])
    print(df.iloc[[0, 1]])

    # 获取第1行name列的值
    print("获取第1行name列的值", df.loc[0, 'name'])

    # 计数、平均数、标准差、最小值、25% 50% 75% 位置的值、最大值
    print(df.groupby("sex").describe())

    # 排序
    print(df.sort_values(["age", "height"], ascending=[False, True]))